<!DOCTYPE html><html lang="zh-CN" data-theme="light"><head><meta charset="UTF-8"><meta http-equiv="X-UA-Compatible" content="IE=edge"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Reality | Reality</title><meta name="keywords" content="Java, 全栈"><meta name="author" content="dtyy"><meta name="copyright" content="dtyy"><meta name="format-detection" content="telephone=no"><meta name="theme-color" content="#ffffff"><meta name="description" content="1 配置哨兵从Redis源码包拷贝创建哨兵核心文件sentine.conf。 1.1 普通配置# 关闭保护模式，允许哨兵访问所有节点 protected-mode no # 默认端口 port 26379 # 设置后台运行 daemonize yes # 进程文件 pidfile &#x2F;usr&#x2F;local&#x2F;redis&#x2F;sentinel&#x2F;redis-sentinel.pid # 日志输出文件 log">
<meta property="og:type" content="article">
<meta property="og:title" content="Reality">
<meta property="og:url" content="https://dtyytop.gitee.io/2021/05/13/devnotes/ji-qun-yan-jin/redis/redis-shao-bing-ji-zhi-yu-shi-xian/index.html">
<meta property="og:site_name" content="Reality">
<meta property="og:description" content="1 配置哨兵从Redis源码包拷贝创建哨兵核心文件sentine.conf。 1.1 普通配置# 关闭保护模式，允许哨兵访问所有节点 protected-mode no # 默认端口 port 26379 # 设置后台运行 daemonize yes # 进程文件 pidfile &#x2F;usr&#x2F;local&#x2F;redis&#x2F;sentinel&#x2F;redis-sentinel.pid # 日志输出文件 log">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/dtyytop/blogimage/raw/master/img/cover/20210525222615.jpg">
<meta property="article:published_time" content="2021-05-13T14:22:22.337Z">
<meta property="article:modified_time" content="2021-05-13T14:22:22.337Z">
<meta property="article:author" content="dtyy">
<meta property="article:tag" content="Java, 全栈">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://gitee.com/dtyytop/blogimage/raw/master/img/cover/20210525222615.jpg"><link rel="shortcut icon" href="/img/favicon.png"><link rel="canonical" href="https://dtyytop.gitee.io/2021/05/13/devnotes/ji-qun-yan-jin/redis/redis-shao-bing-ji-zhi-yu-shi-xian/"><link rel="preconnect" href="//cdn.jsdelivr.net"/><link rel="preconnect" href="//busuanzi.ibruce.info"/><meta/><link rel="stylesheet" href="/css/index.css"><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@fortawesome/fontawesome-free/css/all.min.css" media="print" onload="this.media='all'"><script>const GLOBAL_CONFIG = { 
  root: '/',
  algolia: undefined,
  localSearch: {"path":"search.xml","languages":{"hits_empty":"找不到您查询的内容：${query}"}},
  translate: undefined,
  noticeOutdate: undefined,
  highlight: {"plugin":"prismjs","highlightCopy":true,"highlightLang":true,"highlightHeightLimit":false},
  copy: {
    success: '复制成功',
    error: '复制错误',
    noSupport: '浏览器不支持'
  },
  relativeDate: {
    homepage: false,
    post: true
  },
  runtime: '',
  date_suffix: {
    just: '刚刚',
    min: '分钟前',
    hour: '小时前',
    day: '天前',
    month: '个月前'
  },
  copyright: {"limitCount":50,"languages":{"author":"作者: dtyy","link":"链接: ","source":"来源: Reality","info":"著作权归作者所有。商业转载请联系作者获得授权，非商业转载请注明出处。"}},
  lightbox: 'fancybox',
  Snackbar: undefined,
  source: {
    jQuery: 'https://cdn.jsdelivr.net/npm/jquery@latest/dist/jquery.min.js',
    justifiedGallery: {
      js: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/js/jquery.justifiedGallery.min.js',
      css: 'https://cdn.jsdelivr.net/npm/justifiedGallery/dist/css/justifiedGallery.min.css'
    },
    fancybox: {
      js: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.js',
      css: 'https://cdn.jsdelivr.net/npm/@fancyapps/fancybox@latest/dist/jquery.fancybox.min.css'
    }
  },
  isPhotoFigcaption: false,
  islazyload: false,
  isanchor: false
}</script><script id="config-diff">var GLOBAL_CONFIG_SITE = {
  title: 'Reality',
  isPost: true,
  isHome: false,
  isHighlightShrink: false,
  isToc: true,
  postUpdate: '2021-05-13 22:22:22'
}</script><noscript><style type="text/css">
  #nav {
    opacity: 1
  }
  .justified-gallery img {
    opacity: 1
  }

  #recent-posts time,
  #post-meta time {
    display: inline !important
  }
</style></noscript><script>(win=>{
    win.saveToLocal = {
      set: function setWithExpiry(key, value, ttl) {
        if (ttl === 0) return
        const now = new Date()
        const expiryDay = ttl * 86400000
        const item = {
          value: value,
          expiry: now.getTime() + expiryDay,
        }
        localStorage.setItem(key, JSON.stringify(item))
      },

      get: function getWithExpiry(key) {
        const itemStr = localStorage.getItem(key)

        if (!itemStr) {
          return undefined
        }
        const item = JSON.parse(itemStr)
        const now = new Date()

        if (now.getTime() > item.expiry) {
          localStorage.removeItem(key)
          return undefined
        }
        return item.value
      }
    }
  
    win.getScript = url => new Promise((resolve, reject) => {
      const script = document.createElement('script')
      script.src = url
      script.async = true
      script.onerror = reject
      script.onload = script.onreadystatechange = function() {
        const loadState = this.readyState
        if (loadState && loadState !== 'loaded' && loadState !== 'complete') return
        script.onload = script.onreadystatechange = null
        resolve()
      }
      document.head.appendChild(script)
    })
  
      win.activateDarkMode = function () {
        document.documentElement.setAttribute('data-theme', 'dark')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#0d0d0d')
        }
      }
      win.activateLightMode = function () {
        document.documentElement.setAttribute('data-theme', 'light')
        if (document.querySelector('meta[name="theme-color"]') !== null) {
          document.querySelector('meta[name="theme-color"]').setAttribute('content', '#ffffff')
        }
      }
      const t = saveToLocal.get('theme')
    
          if (t === 'dark') activateDarkMode()
          else if (t === 'light') activateLightMode()
        
      const asideStatus = saveToLocal.get('aside-status')
      if (asideStatus !== undefined) {
        if (asideStatus === 'hide') {
          document.documentElement.classList.add('hide-aside')
        } else {
          document.documentElement.classList.remove('hide-aside')
        }
      }
    
    const fontSizeVal = saveToLocal.get('global-font-size')
    if (fontSizeVal !== undefined) {
      document.documentElement.style.setProperty('--global-font-size', fontSizeVal + 'px')
    }
    })(window)</script><meta name="generator" content="Hexo 5.4.0"><link rel="alternate" href="/atom.xml" title="Reality" type="application/atom+xml">

<style>.github-emoji { position: relative; display: inline-block; width: 1.2em; min-height: 1.2em; overflow: hidden; vertical-align: top; color: transparent; }  .github-emoji > span { position: relative; z-index: 10; }  .github-emoji img, .github-emoji .fancybox { margin: 0 !important; padding: 0 !important; border: none !important; outline: none !important; text-decoration: none !important; user-select: none !important; cursor: auto !important; }  .github-emoji img { height: 1.2em !important; width: 1.2em !important; position: absolute !important; left: 50% !important; top: 50% !important; transform: translate(-50%, -50%) !important; user-select: none !important; cursor: auto !important; } .github-emoji-fallback { color: inherit; } .github-emoji-fallback img { opacity: 0 !important; }</style>
</head><body><div id="loading-box"><div class="loading-left-bg"></div><div class="loading-right-bg"></div><div class="spinner-box"><div class="configure-border-1"><div class="configure-core"></div></div><div class="configure-border-2"><div class="configure-core"></div></div><div class="loading-word">加载中...</div></div></div><div id="sidebar"><div id="menu-mask"></div><div id="sidebar-menus"><div class="author-avatar"><img class="avatar-img" src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="onerror=null;src='/img/friend_404.gif'" alt="avatar"/></div><div class="site-data"><div class="data-item is-center"><div class="data-item-link"><a href="/archives/"><div class="headline">文章</div><div class="length-num">95</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/tags/"><div class="headline">标签</div><div class="length-num">28</div></a></div></div><div class="data-item is-center"><div class="data-item-link"><a href="/categories/"><div class="headline">分类</div><div class="length-num">16</div></a></div></div></div><hr/><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 清单</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/gallery/"><i class="fa-fw fas fa-images"></i><span> 图片</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div></div></div><div class="post" id="body-wrap"><header class="post-bg" id="page-header" style="background-image: url('https://gitee.com/dtyytop/blogimage/raw/master/img/cover/20210525222615.jpg')"><nav id="nav"><span id="blog_name"><a id="site-name" href="/">Reality</a></span><div id="menus"><div id="search-button"><a class="site-page social-icon search"><i class="fas fa-search fa-fw"></i><span> 搜索</span></a></div><div class="menus_items"><div class="menus_item"><a class="site-page" href="/"><i class="fa-fw fas fa-home"></i><span> 首页</span></a></div><div class="menus_item"><a class="site-page" href="/archives/"><i class="fa-fw fas fa-archive"></i><span> 归档</span></a></div><div class="menus_item"><a class="site-page" href="/tags/"><i class="fa-fw fas fa-tags"></i><span> 标签</span></a></div><div class="menus_item"><a class="site-page" href="/categories/"><i class="fa-fw fas fa-folder-open"></i><span> 分类</span></a></div><div class="menus_item"><a class="site-page" href="javascript:void(0);"><i class="fa-fw fas fa-list"></i><span> 清单</span><i class="fas fa-chevron-down expand"></i></a><ul class="menus_item_child"><li><a class="site-page child" href="/music/"><i class="fa-fw fas fa-music"></i><span> 音乐</span></a></li><li><a class="site-page child" href="/gallery/"><i class="fa-fw fas fa-images"></i><span> 图片</span></a></li><li><a class="site-page child" href="/movies/"><i class="fa-fw fas fa-video"></i><span> 电影</span></a></li></ul></div><div class="menus_item"><a class="site-page" href="/link/"><i class="fa-fw fas fa-link"></i><span> 友链</span></a></div><div class="menus_item"><a class="site-page" href="/about/"><i class="fa-fw fas fa-heart"></i><span> 关于</span></a></div></div><div id="toggle-menu"><a class="site-page"><i class="fas fa-bars fa-fw"></i></a></div></div></nav><div id="post-info"><h1 class="post-title">无题</h1><div id="post-meta"><div class="meta-firstline"><span class="post-meta-date"><i class="far fa-calendar-alt fa-fw post-meta-icon"></i><span class="post-meta-label">发表于</span><time class="post-meta-date-created" datetime="2021-05-13T14:22:22.337Z" title="发表于 2021-05-13 22:22:22">2021-05-13</time><span class="post-meta-separator">|</span><i class="fas fa-history fa-fw post-meta-icon"></i><span class="post-meta-label">更新于</span><time class="post-meta-date-updated" datetime="2021-05-13T14:22:22.337Z" title="更新于 2021-05-13 22:22:22">2021-05-13</time></span></div><div class="meta-secondline"><span class="post-meta-separator">|</span><span class="post-meta-wordcount"><i class="far fa-file-word fa-fw post-meta-icon"></i><span class="post-meta-label">字数总计:</span><span class="word-count">1.8k</span><span class="post-meta-separator">|</span><i class="far fa-clock fa-fw post-meta-icon"></i><span class="post-meta-label">阅读时长:</span><span>8分钟</span></span><span class="post-meta-separator">|</span><span class="post-meta-pv-cv" id="" data-flag-title=""><i class="far fa-eye fa-fw post-meta-icon"></i><span class="post-meta-label">阅读量:</span><span id="busuanzi_value_page_pv"></span></span></div></div></div></header><main class="layout" id="content-inner"><div id="post"><article class="post-content" id="article-container"><blockquote>
</blockquote>
<h2 id="1-配置哨兵"><a href="#1-配置哨兵" class="headerlink" title="1 配置哨兵"></a>1 配置哨兵</h2><p>从Redis源码包拷贝创建哨兵核心文件sentine.conf。</p>
<h3 id="1-1-普通配置"><a href="#1-1-普通配置" class="headerlink" title="1.1 普通配置"></a>1.1 普通配置</h3><pre class="line-numbers language-shell" data-language="shell"><code class="language-shell"><span class="token comment"># 关闭保护模式，允许哨兵访问所有节点</span>
protected-mode no
<span class="token comment"># 默认端口</span>
port <span class="token number">26379</span>
<span class="token comment"># 设置后台运行</span>
daemonize <span class="token function">yes</span>
<span class="token comment"># 进程文件</span>
pidfile /usr/local/redis/sentinel/redis-sentinel.pid
<span class="token comment"># 日志输出文件</span>
logfile <span class="token string">"/usr/local/redis/sentinel/redis-sentinel.log"</span>
<span class="token comment"># 工作目录</span>
<span class="token function">dir</span> <span class="token string">"/usr/local/redis/sentinel"</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h3 id="1-2-核心配置"><a href="#1-2-核心配置" class="headerlink" title="1.2 核心配置"></a>1.2 核心配置</h3><pre class="line-numbers language-shell" data-language="shell"><code class="language-shell">sentinel monitor master-130 <span class="token number">192.168</span>.233.130 <span class="token number">6379</span> <span class="token number">2</span><span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>

<p>通知sentinel监视master-130主节点。在至少2个sentinel同意时，判定主节点失效（ODOWN状态）。不过，无论多少个sentinel同意才能判断主节点失效，一个sentinel都需要经过多数sentinel同意才能完成自动故障迁移。</p>
<p>sentinel自动检测从节点，重写sentinel配置。当从节点提升为主节点时，也会重写配置文件。</p>
<pre class="line-numbers language-shell" data-language="shell"><code class="language-shell"><span class="token comment"># 密码</span>
sentinel auth-pass master-130 <span class="token number">123456</span>
<span class="token comment"># master被sentinel视为主观下线的间隔时间</span>
sentinel down-after-milliseconds master-130 <span class="token number">5000</span>
<span class="token comment"># 剩余slaves重新与新master同步时的并行个数</span>
sentinel parallel-syncs master-130 <span class="token number">1</span>
<span class="token comment"># 指定故障转移超时时间，默认3分钟</span>
<span class="token comment"># 主备切换的超时时间，哨兵要去做故障转移，这个时候哨兵也是一个进程，如果他没有去执行，超过这个时间后，会由其他的哨兵来处理</span>
sentinel failover-timeout master-130 <span class="token number">180000</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h3 id="1-3-测试sentinel"><a href="#1-3-测试sentinel" class="headerlink" title="1.3 测试sentinel"></a>1.3 测试sentinel</h3><p>Redis sentinel主从节点是相同的。远程传输sentinel配置到slave节点。</p>
<pre class="line-numbers language-shell" data-language="shell"><code class="language-shell"><span class="token comment"># 配置131和132两个节点</span>
<span class="token punctuation">[</span>root@localhost redis<span class="token punctuation">]</span><span class="token comment"># scp sentinel.conf root@192.168.233.132:/usr/local/redis/</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span></span></code></pre>

<p> 分别启动三个节点的哨兵</p>
<pre class="line-numbers language-shell" data-language="shell"><code class="language-shell"><span class="token punctuation">[</span>root@192 redis<span class="token punctuation">]</span><span class="token comment"># redis-sentinel sentinel.conf</span>
<span class="token punctuation">[</span>root@192 redis<span class="token punctuation">]</span><span class="token comment"># tail -f sentinel/redis-sentinel.log </span>
<span class="token number">23278</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">19</span>:40:52.341 <span class="token comment"># oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo</span>
<span class="token number">23278</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">19</span>:40:52.341 <span class="token comment"># Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=23278, just started</span>
<span class="token number">23278</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">19</span>:40:52.341 <span class="token comment"># Configuration loaded</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">19</span>:40:52.344 * Running <span class="token assign-left variable">mode</span><span class="token operator">=</span>sentinel, <span class="token assign-left variable">port</span><span class="token operator">=</span><span class="token number">26379</span>.
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">19</span>:40:52.344 <span class="token comment"># WARNING: The TCP backlog setting of 511 cannot be enforced because /proc/sys/net/core/somaxconn is set to the lower value of 128.</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">19</span>:40:52.345 <span class="token comment"># Sentinel ID is 43eddbbc48075fdde4bcd6f445c78770f1acbe66</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">19</span>:40:52.345 <span class="token comment"># +monitor master master-130 192.168.233.130 6379 quorum 2</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">19</span>:40:52.346 * +slave slave <span class="token number">192.168</span>.233.131:6379 <span class="token number">192.168</span>.233.131 <span class="token number">6379</span> @ master-130 <span class="token number">192.168</span>.233.130 <span class="token number">6379</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">19</span>:40:52.348 * +slave slave <span class="token number">192.168</span>.233.132:6379 <span class="token number">192.168</span>.233.132 <span class="token number">6379</span> @ master-130 <span class="token number">192.168</span>.233.130 <span class="token number">6379</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">19</span>:42:08.523 * +sentinel sentinel ee5e3931d9370f0ad178129868257c33999c91fb <span class="token number">192.168</span>.233.131 <span class="token number">26379</span> @ master-130 <span class="token number">192.168</span>.233.130 <span class="token number">6379</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">19</span>:42:29.670 * +sentinel sentinel eba6988db3633bf519c9c154691765d10bee4479 <span class="token number">192.168</span>.233.132 <span class="token number">26379</span> @ master-130 <span class="token number">192.168</span>.233.130 <span class="token number">6379</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<h4 id="挂掉master节点"><a href="#挂掉master节点" class="headerlink" title="挂掉master节点"></a>挂掉master节点</h4><p>此时，挂掉master 130节点，会重新选举出新的master节点。</p>
<pre class="line-numbers language-shell" data-language="shell"><code class="language-shell"><span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:39:06.302 <span class="token comment"># +sdown master master-130 192.168.233.130 6379</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:39:06.355 <span class="token comment"># +odown master master-130 192.168.233.130 6379 #quorum 2/2</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:39:06.355 <span class="token comment"># +new-epoch 1</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:39:06.355 <span class="token comment"># +try-failover master master-130 192.168.233.130 6379</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:39:06.357 <span class="token comment"># +vote-for-leader 43eddbbc48075fdde4bcd6f445c78770f1acbe66 1</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:39:06.361 <span class="token comment"># ee5e3931d9370f0ad178129868257c33999c91fb voted for 43eddbbc48075fdde4bcd6f445c78770f1acbe66 1</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:39:06.367 <span class="token comment"># eba6988db3633bf519c9c154691765d10bee4479 voted for 43eddbbc48075fdde4bcd6f445c78770f1acbe66 1</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:39:06.413 <span class="token comment"># +elected-leader master master-130 192.168.233.130 6379</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:39:06.413 <span class="token comment"># +failover-state-select-slave master master-130 192.168.233.130 6379</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:39:06.476 <span class="token comment"># +selected-slave slave 192.168.233.131:6379 192.168.233.131 6379 @ master-130 192.168.233.130 6379</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:39:06.476 * +failover-state-send-slaveof-noone slave <span class="token number">192.168</span>.233.131:6379 <span class="token number">192.168</span>.233.131 <span class="token number">6379</span> @ master-130 <span class="token number">192.168</span>.233.130 <span class="token number">6379</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:39:06.561 * +failover-state-wait-promotion slave <span class="token number">192.168</span>.233.131:6379 <span class="token number">192.168</span>.233.131 <span class="token number">6379</span> @ master-130 <span class="token number">192.168</span>.233.130 <span class="token number">6379</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:39:06.951 <span class="token comment"># +promoted-slave slave 192.168.233.131:6379 192.168.233.131 6379 @ master-130 192.168.233.130 6379</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:39:06.951 <span class="token comment"># +failover-state-reconf-slaves master master-130 192.168.233.130 6379</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:39:07.031 * +slave-reconf-sent slave <span class="token number">192.168</span>.233.132:6379 <span class="token number">192.168</span>.233.132 <span class="token number">6379</span> @ master-130 <span class="token number">192.168</span>.233.130 <span class="token number">6379</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:39:07.440 <span class="token comment"># -odown master master-130 192.168.233.130 6379</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:39:07.991 * +slave-reconf-inprog slave <span class="token number">192.168</span>.233.132:6379 <span class="token number">192.168</span>.233.132 <span class="token number">6379</span> @ master-130 <span class="token number">192.168</span>.233.130 <span class="token number">6379</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:39:07.991 * +slave-reconf-done slave <span class="token number">192.168</span>.233.132:6379 <span class="token number">192.168</span>.233.132 <span class="token number">6379</span> @ master-130 <span class="token number">192.168</span>.233.130 <span class="token number">6379</span>
<span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:39:08.057 <span class="token comment"># +failover-end master master-130 192.168.233.130 6379</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>

<p>此时，131节点被选举成为新的master节点，132节点仍是salve节点。</p>
<pre class="line-numbers language-redis" data-language="redis"><code class="language-redis">&gt; info replication<span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>

<h4 id="重启原master-130节点"><a href="#重启原master-130节点" class="headerlink" title="重启原master  130节点"></a>重启原master  130节点</h4><p>重启130节点，并且登录客户端校验。</p>
<pre class="line-numbers language-shell" data-language="shell"><code class="language-shell"><span class="token number">23279</span>:X <span class="token number">11</span> Apr <span class="token number">2021</span> <span class="token number">21</span>:56:18.779 * +convert-to-slave slave <span class="token number">192.168</span>.233.131:6379 <span class="token number">192.168</span>.233.131 <span class="token number">6379</span> @ master-130 <span class="token number">192.168</span>.233.132 <span class="token number">6379</span><span aria-hidden="true" class="line-numbers-rows"><span></span></span></code></pre>

<blockquote>
<p>一般master数据无法同步给slave的方案检查为如下：</p>
<ol>
<li>网络通信问题，要保证互相ping通，内网互通。</li>
<li>关闭防火墙，对应的端口开放（虚拟机中建议永久关闭防火墙，云服务器的话需要保证内网互通）。</li>
<li>统一所有的密码，通过逐台检查机器以防某个节点被遗漏。</li>
</ol>
</blockquote>
<h4 id="查看哨兵配置"><a href="#查看哨兵配置" class="headerlink" title="查看哨兵配置"></a>查看哨兵配置</h4><pre class="line-numbers language-shell" data-language="shell"><code class="language-shell"><span class="token punctuation">[</span>root@192 redis<span class="token punctuation">]</span><span class="token comment"># redis-cli -p 26379</span>
<span class="token number">127.0</span>.0.1:2637<span class="token operator"><span class="token file-descriptor important">9</span>&gt;</span> sentinel master master-130
<span class="token number">127.0</span>.0.1:2637<span class="token operator"><span class="token file-descriptor important">9</span>&gt;</span> sentinel slaves master-130
<span class="token comment"># master-130是哨兵群组名</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span></span></code></pre>

<h3 id="4-SpringBoot集成Redis哨兵"><a href="#4-SpringBoot集成Redis哨兵" class="headerlink" title="4 SpringBoot集成Redis哨兵"></a>4 SpringBoot集成Redis哨兵</h3><pre class="line-numbers language-yaml" data-language="yaml"><code class="language-yaml"><span class="token key atrule">spring</span><span class="token punctuation">:</span>
  <span class="token key atrule">redis</span><span class="token punctuation">:</span>
    <span class="token comment"># 单机</span>
<span class="token comment">#    database: 0</span>
<span class="token comment">#    host: 192.168.233.130</span>
<span class="token comment">#    port: 6379</span>
<span class="token comment">#    password: 123456</span>
    <span class="token comment"># 哨兵模式</span>
    <span class="token key atrule">database</span><span class="token punctuation">:</span> <span class="token number">0</span> <span class="token comment"># redis库</span>
    <span class="token key atrule">password</span><span class="token punctuation">:</span> <span class="token number">123456</span> <span class="token comment"># 密码</span>
    <span class="token key atrule">sentinel</span><span class="token punctuation">:</span>
      <span class="token key atrule">master</span><span class="token punctuation">:</span> master<span class="token punctuation">-</span><span class="token number">130</span> <span class="token comment"># 哨兵群组名</span>
      <span class="token key atrule">nodes</span><span class="token punctuation">:</span> 192.168.233.130<span class="token punctuation">:</span><span class="token number">26379</span><span class="token punctuation">,</span>192.168.233.131<span class="token punctuation">:</span><span class="token number">26379</span><span class="token punctuation">,</span>192.168.233.132<span class="token punctuation">:</span><span class="token number">26379</span> <span class="token comment"># 节点套接字</span><span aria-hidden="true" class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span></code></pre>



<h2 id="2-哨兵运行原理"><a href="#2-哨兵运行原理" class="headerlink" title="2 哨兵运行原理"></a>2 哨兵运行原理</h2><h3 id="2-1-主观下线和客观下线"><a href="#2-1-主观下线和客观下线" class="headerlink" title="2.1 主观下线和客观下线"></a>2.1 主观下线和客观下线</h3><p>sentinel每秒向所知的所有redis节点、sentinel实例发送ping命令，并得到有效回复。如果指定时间内未收到回复，视为主观下线。</p>
<ul>
<li>主观下线（Subjectively Down， 简称 SDOWN）指的是单个 Sentinel 实例对服务器做出的下线判断。</li>
<li>客观下线（Objectively Down， 简称 ODOWN）指的是多个 Sentinel 实例在对同一个服务器做出 SDOWN 判断， 并且通过 SENTINEL is-master-down-by-addr 命令互相交流之后， 得出的服务器下线判断。 </li>
</ul>
<p>客观下线条件<strong>只适用于主服务器</strong>： 对于任何其他类型的 Redis 实例， Sentinel 在将它们判断为下线前不需要进行协商， 所以从服务器或者其他 Sentinel 永远不会达到客观下线条件。</p>
<h3 id="2-2-sentinel发布订阅"><a href="#2-2-sentinel发布订阅" class="headerlink" title="2.2 sentinel发布订阅"></a>2.2 sentinel发布订阅</h3><p>一个 Sentinel 可以与其他多个 Sentinel 进行连接， 各个 Sentinel 之间可以互相检查对方的可用性， 并进行信息交换。 Sentinel 可以通过发布与订阅功能来自动发现正在监视相同主服务器的其他 Sentinel ， 这一功能是通过向频道 <strong>sentinel</strong>:hello 发送信息来实现的。</p>
<h3 id="2-3-故障迁移"><a href="#2-3-故障迁移" class="headerlink" title="2.3 故障迁移"></a>2.3 故障迁移</h3><p>包括选举新master、slave升级为master节点、通知其他sentinel、更新其他从节点数据。</p>
<h3 id="2-4-部署约定"><a href="#2-4-部署约定" class="headerlink" title="2.4 部署约定"></a>2.4 部署约定</h3><ul>
<li><p>哨兵节点要有至少3个或者奇数个节点。有利于客观下线和选举。</p>
</li>
<li><p>哨兵分布式部署在不同计算机节点上。哨兵的用途就是高可用，放到一台上不够安全。</p>
</li>
<li><p>一组哨兵只监听一组主从。</p>
</li>
</ul>
<h2 id="参考资料"><a href="#参考资料" class="headerlink" title="参考资料"></a>参考资料</h2><p>重要资料：<a target="_blank" rel="noopener" href="http://www.redis.cn/topics/sentinel.html">http://www.redis.cn/topics/sentinel.html</a></p>
</article><div class="post-copyright"><div class="post-copyright__author"><span class="post-copyright-meta">文章作者: </span><span class="post-copyright-info"><a href="mailto:undefined">dtyy</a></span></div><div class="post-copyright__type"><span class="post-copyright-meta">文章链接: </span><span class="post-copyright-info"><a href="https://dtyytop.gitee.io/2021/05/13/devnotes/ji-qun-yan-jin/redis/redis-shao-bing-ji-zhi-yu-shi-xian/">https://dtyytop.gitee.io/2021/05/13/devnotes/ji-qun-yan-jin/redis/redis-shao-bing-ji-zhi-yu-shi-xian/</a></span></div><div class="post-copyright__notice"><span class="post-copyright-meta">版权声明: </span><span class="post-copyright-info">本博客所有文章除特别声明外，均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank">CC BY-NC-SA 4.0</a> 许可协议。转载请注明来自 <a href="https://dtyytop.gitee.io" target="_blank">Reality</a>！</span></div></div><div class="tag_share"><div class="post-meta__tag-list"></div><div class="post_share"><div class="social-share" data-image="https://gitee.com/dtyytop/blogimage/raw/master/img/cover/20210525222615.jpg" data-sites="facebook,twitter,wechat,weibo,qq"></div><link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/social-share.js/dist/css/share.min.css" media="print" onload="this.media='all'"><script src="https://cdn.jsdelivr.net/npm/social-share.js/dist/js/social-share.min.js" defer></script></div></div><div class="post-reward"><div class="reward-button button--animated"><i class="fas fa-qrcode"></i> 打赏</div><div class="reward-main"><ul class="reward-all"><li class="reward-item"><a href="https://gitee.com/dtyytop/blogimage/raw/master/img/20210515001034.png" target="_blank"><img class="post-qr-code-img" src="https://gitee.com/dtyytop/blogimage/raw/master/img/20210515001034.png" alt="wechat"/></a><div class="post-qr-code-desc">wechat</div></li><li class="reward-item"><a href="https://gitee.com/dtyytop/blogimage/raw/master/img/20210515001009.png" target="_blank"><img class="post-qr-code-img" src="https://gitee.com/dtyytop/blogimage/raw/master/img/20210515001009.png" alt="alipay"/></a><div class="post-qr-code-desc">alipay</div></li></ul></div></div><nav class="pagination-post" id="pagination"><div class="prev-post pull-left"><a href="/2021/05/13/devnotes/ji-qun-yan-jin/redis/redis-xian-cheng-mo-xing/"><img class="prev-cover" src="https://gitee.com/dtyytop/blogimage/raw/master/img/cover/20210525222629.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of previous post"><div class="pagination-info"><div class="label">上一篇</div><div class="prev_info"></div></div></a></div><div class="next-post pull-right"><a href="/2021/05/13/devnotes/ji-qun-yan-jin/redis/redis-ji-qun/"><img class="next-cover" src="https://gitee.com/dtyytop/blogimage/raw/master/img/cover/20210525222554.jpg" onerror="onerror=null;src='/img/404.jpg'" alt="cover of next post"><div class="pagination-info"><div class="label">下一篇</div><div class="next_info"></div></div></a></div></nav></div><div class="aside-content" id="aside-content"><div class="card-widget card-info"><div class="card-info-avatar is-center"><img class="avatar-img" src="https://i.loli.net/2021/02/24/5O1day2nriDzjSu.png" onerror="this.onerror=null;this.src='/img/friend_404.gif'" alt="avatar"/><div class="author-info__name">dtyy</div><div class="author-info__description">Java全栈</div></div><div class="card-info-data"><div class="card-info-data-item is-center"><a href="/archives/"><div class="headline">文章</div><div class="length-num">95</div></a></div><div class="card-info-data-item is-center"><a href="/tags/"><div class="headline">标签</div><div class="length-num">28</div></a></div><div class="card-info-data-item is-center"><a href="/categories/"><div class="headline">分类</div><div class="length-num">16</div></a></div></div><a class="button--animated" id="card-info-btn" target="_blank" rel="noopener" href="https://gitee.com/dtyytop"><i class="fab fa-github"></i><span>Follow Me</span></a><div class="card-info-social-icons is-center"><a class="social-icon" href="https://gitee.com/dtyytop" target="_blank" title="Github"><i class="fab fa-github"></i></a><a class="social-icon" href="mailto:1607961042@qq.com" target="_blank" title="Email"><i class="fas fa-envelope"></i></a></div></div><div class="card-widget card-announcement"><div class="item-headline"><i class="fas fa-bullhorn card-announcement-animation"></i><span>公告</span></div><div class="announcement_content">This is my Blog</div></div><div class="sticky_layout"><div class="card-widget" id="card-toc"><div class="item-headline"><i class="fas fa-stream"></i><span>目录</span></div><div class="toc-content"><ol class="toc"><li class="toc-item toc-level-2"><a class="toc-link" href="#1-%E9%85%8D%E7%BD%AE%E5%93%A8%E5%85%B5"><span class="toc-number">1.</span> <span class="toc-text">1 配置哨兵</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#1-1-%E6%99%AE%E9%80%9A%E9%85%8D%E7%BD%AE"><span class="toc-number">1.1.</span> <span class="toc-text">1.1 普通配置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-2-%E6%A0%B8%E5%BF%83%E9%85%8D%E7%BD%AE"><span class="toc-number">1.2.</span> <span class="toc-text">1.2 核心配置</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#1-3-%E6%B5%8B%E8%AF%95sentinel"><span class="toc-number">1.3.</span> <span class="toc-text">1.3 测试sentinel</span></a><ol class="toc-child"><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%8C%82%E6%8E%89master%E8%8A%82%E7%82%B9"><span class="toc-number">1.3.1.</span> <span class="toc-text">挂掉master节点</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E9%87%8D%E5%90%AF%E5%8E%9Fmaster-130%E8%8A%82%E7%82%B9"><span class="toc-number">1.3.2.</span> <span class="toc-text">重启原master  130节点</span></a></li><li class="toc-item toc-level-4"><a class="toc-link" href="#%E6%9F%A5%E7%9C%8B%E5%93%A8%E5%85%B5%E9%85%8D%E7%BD%AE"><span class="toc-number">1.3.3.</span> <span class="toc-text">查看哨兵配置</span></a></li></ol></li><li class="toc-item toc-level-3"><a class="toc-link" href="#4-SpringBoot%E9%9B%86%E6%88%90Redis%E5%93%A8%E5%85%B5"><span class="toc-number">1.4.</span> <span class="toc-text">4 SpringBoot集成Redis哨兵</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#2-%E5%93%A8%E5%85%B5%E8%BF%90%E8%A1%8C%E5%8E%9F%E7%90%86"><span class="toc-number">2.</span> <span class="toc-text">2 哨兵运行原理</span></a><ol class="toc-child"><li class="toc-item toc-level-3"><a class="toc-link" href="#2-1-%E4%B8%BB%E8%A7%82%E4%B8%8B%E7%BA%BF%E5%92%8C%E5%AE%A2%E8%A7%82%E4%B8%8B%E7%BA%BF"><span class="toc-number">2.1.</span> <span class="toc-text">2.1 主观下线和客观下线</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-2-sentinel%E5%8F%91%E5%B8%83%E8%AE%A2%E9%98%85"><span class="toc-number">2.2.</span> <span class="toc-text">2.2 sentinel发布订阅</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-3-%E6%95%85%E9%9A%9C%E8%BF%81%E7%A7%BB"><span class="toc-number">2.3.</span> <span class="toc-text">2.3 故障迁移</span></a></li><li class="toc-item toc-level-3"><a class="toc-link" href="#2-4-%E9%83%A8%E7%BD%B2%E7%BA%A6%E5%AE%9A"><span class="toc-number">2.4.</span> <span class="toc-text">2.4 部署约定</span></a></li></ol></li><li class="toc-item toc-level-2"><a class="toc-link" href="#%E5%8F%82%E8%80%83%E8%B5%84%E6%96%99"><span class="toc-number">3.</span> <span class="toc-text">参考资料</span></a></li></ol></div></div><div class="card-widget card-recent-post"><div class="item-headline"><i class="fas fa-history"></i><span>最新文章</span></div><div class="aside-list"><div class="aside-list-item"><a class="thumbnail" href="/2021/06/02/devnotes/ji-qun-yan-jin/nginx/1.3-nginx-jin-cheng-mo-xing-yu-shi-jian-chu-li-ji-zhi/" title="Nginx进程模型"><img src="https://gitee.com/dtyytop/blogimage/raw/master/img/cover/20210525222600.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Nginx进程模型"/></a><div class="content"><a class="title" href="/2021/06/02/devnotes/ji-qun-yan-jin/nginx/1.3-nginx-jin-cheng-mo-xing-yu-shi-jian-chu-li-ji-zhi/" title="Nginx进程模型">Nginx进程模型</a><time datetime="2021-06-01T16:00:00.000Z" title="发表于 2021-06-02 00:00:00">2021-06-02</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/06/02/devnotes/ji-qun-yan-jin/nginx/1.4-nginx-he-xin-wen-jian-jie-gou-fen-xi/" title="Nginx核心配置结构"><img src="https://gitee.com/dtyytop/blogimage/raw/master/img/cover/20210525222629.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Nginx核心配置结构"/></a><div class="content"><a class="title" href="/2021/06/02/devnotes/ji-qun-yan-jin/nginx/1.4-nginx-he-xin-wen-jian-jie-gou-fen-xi/" title="Nginx核心配置结构">Nginx核心配置结构</a><time datetime="2021-06-01T16:00:00.000Z" title="发表于 2021-06-02 00:00:00">2021-06-02</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/05/30/devnotes/ji-qun-yan-jin/nginx/1.2-wei-shi-me-xuan-ze-nginx/" title="集群、代理与Nginx"><img src="https://gitee.com/dtyytop/blogimage/raw/master/img/cover/20210525222629.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="集群、代理与Nginx"/></a><div class="content"><a class="title" href="/2021/05/30/devnotes/ji-qun-yan-jin/nginx/1.2-wei-shi-me-xuan-ze-nginx/" title="集群、代理与Nginx">集群、代理与Nginx</a><time datetime="2021-05-29T16:00:00.000Z" title="发表于 2021-05-30 00:00:00">2021-05-30</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/05/30/devnotes/ji-qun-yan-jin/redis/redis-zhu-cong-fu-zhi-yu-yuan-li/" title="Redis主从复制架构与原理"><img src="https://gitee.com/dtyytop/blogimage/raw/master/img/cover/20210525222646.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Redis主从复制架构与原理"/></a><div class="content"><a class="title" href="/2021/05/30/devnotes/ji-qun-yan-jin/redis/redis-zhu-cong-fu-zhi-yu-yuan-li/" title="Redis主从复制架构与原理">Redis主从复制架构与原理</a><time datetime="2021-05-29T16:00:00.000Z" title="发表于 2021-05-30 00:00:00">2021-05-30</time></div></div><div class="aside-list-item"><a class="thumbnail" href="/2021/05/30/devnotes/ji-qun-yan-jin/redis/redis-chi-jiu-hua-ji-zhi/" title="Redis的两种持久化机制"><img src="https://gitee.com/dtyytop/blogimage/raw/master/img/cover/20210525222634.jpg" onerror="this.onerror=null;this.src='/img/404.jpg'" alt="Redis的两种持久化机制"/></a><div class="content"><a class="title" href="/2021/05/30/devnotes/ji-qun-yan-jin/redis/redis-chi-jiu-hua-ji-zhi/" title="Redis的两种持久化机制">Redis的两种持久化机制</a><time datetime="2021-05-29T16:00:00.000Z" title="发表于 2021-05-30 00:00:00">2021-05-30</time></div></div></div></div></div></div></main><footer id="footer" style="background-image: url('https://gitee.com/dtyytop/blogimage/raw/master/img/cover/20210525222615.jpg')"><div id="footer-wrap"><div class="copyright">&copy;2020 - 2021 By dtyy</div><div class="framework-info"><span>框架 </span><a target="_blank" rel="noopener" href="https://hexo.io">Hexo</a><span class="footer-separator">|</span><span>主题 </span><a target="_blank" rel="noopener" href="https://github.com/jerryc127/hexo-theme-butterfly">Butterfly</a></div></div></footer></div><div id="rightside"><div id="rightside-config-hide"><button id="readmode" type="button" title="阅读模式"><i class="fas fa-book-open"></i></button><button id="font-plus" type="button" title="放大字体"><i class="fas fa-plus"></i></button><button id="font-minus" type="button" title="缩小字体"><i class="fas fa-minus"></i></button><button id="darkmode" type="button" title="浅色和深色模式转换"><i class="fas fa-adjust"></i></button><button id="hide-aside-btn" type="button" title="单栏和双栏切换"><i class="fas fa-arrows-alt-h"></i></button></div><div id="rightside-config-show"><button id="rightside_config" type="button" title="设置"><i class="fas fa-cog fa-spin"></i></button><button class="close" id="mobile-toc-button" type="button" title="目录"><i class="fas fa-list-ul"></i></button><button id="go-up" type="button" title="回到顶部"><i class="fas fa-arrow-up"></i></button></div></div><div id="local-search"><div class="search-dialog"><div class="search-dialog__title" id="local-search-title">本地搜索</div><div id="local-input-panel"><div id="local-search-input"><div class="local-search-box"><input class="local-search-box--input" placeholder="搜索文章" type="text"/></div></div></div><hr/><div id="local-search-results"></div><span class="search-close-button"><i class="fas fa-times"></i></span></div><div id="search-mask"></div></div><div><script src="/js/utils.js"></script><script src="/js/main.js"></script><script src="https://cdn.jsdelivr.net/npm/instant.page/instantpage.min.js" type="module"></script><script src="/js/search/local-search.js"></script><script>var preloader = {
  endLoading: () => {
    document.body.style.overflow = 'auto';
    document.getElementById('loading-box').classList.add("loaded")
  },
  initLoading: () => {
    document.body.style.overflow = '';
    document.getElementById('loading-box').classList.remove("loaded")

  }
}
window.addEventListener('load',preloader.endLoading())</script><div class="js-pjax"></div><script defer="defer" id="ribbon" src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/canvas-ribbon.min.js" size="150" alpha="0.6" zIndex="-1" mobile="false" data-click="false"></script><script src="https://cdn.jsdelivr.net/npm/butterfly-extsrc@1/dist/activate-power-mode.min.js"></script><script>POWERMODE.colorful = true;
POWERMODE.shake = true;
POWERMODE.mobile = false;
document.body.addEventListener('input', POWERMODE);
</script><script async data-pjax src="//busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script></div></body></html>